package springcloudDemo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ThreadLocalRandom;

/**
 *
 */
@SpringBootApplication
@EnableEurekaClient
@RestController
public class SpringCloudEurekaProvider {
    public static void main(String[] args) {
        SpringApplication.run(SpringCloudEurekaProvider.class,args);
    }

    @GetMapping("/index")
    public String index() throws InterruptedException {
        System.out.println("===");
        Thread.sleep(ThreadLocalRandom.current().nextInt(100,3000));
        System.out.println("sleep end");
        return "hello,world";
    }

    @GetMapping("/parameter")
    public String indexWithParameter(@RequestParam(required = true) String name){
        return "hello "+name;
    }

}
